<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <%@include file="../../../res/include/base-head.jsp"%>
	<%@include file="../../../res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/mall/shopCategory.js"></script>
	
</head>
<body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
	    	<form id="query-form" class="search_form clearfix">
	            <dl>
					<dt>类目名称：</dt>
					<dd>
						<input name="name" id="name" type="text" class="txt" maxlength="16"/>
					</dd>
				</dl>
				<dl>
					<dt>级别：</dt>
					<dd>
	                	<select id="level" name="level" class="txt grid-10" onchange="changeLevel(this.value)">
							<option value="1">一级</option>
							<option value="2">二级</option>
						</select>
					</dd>
				</dl>
				<dl id="dl_parentName" class="hide">
					<dt>上级名称：</dt>
					<dd>
						<input name="parentName" id="parentName" type="text" class="txt" maxlength="16"/>
					</dd>
				</dl>
				<dl>
					<dt>种类：</dt>
					<dd>
	                	<select name="type" class="txt grid-10">
							<option value="">请选择</option>
							<option value="1">邻里店</option>
							<option value="2">周边商家</option>
						</select>
					</dd>
				</dl>
	            <p class="search_form_btn">
	            	<input type="button" value="搜索" class="icon_serach" onclick="admin.shopCategory.query()" />
	            	<input type="button" value="添加一级分类" title="添加一级分类" class="icon_serach" onclick="admin.shopCategory.addTop()" />
	            </p>
	        </form>
	  	</div>
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" data-options="url:'${pageContext.request.contextPath}/mall/shop/category/list',toolbar:'#toolbar'">
				<thead>
					<tr>
						<th data-options="field:'name',width:200,align:'center'">类目名称</th>
						<th data-options="field:'parentName',width:200,align:'center'">上级名称</th>
						<th data-options="field:'status',width:80,align:'center',formatter:formatStatus">状态</th>
						<th data-options="field:'type',width:80,align:'center',formatter:formatType">种类</th>
						<th data-options="field:'oidx',width:80,align:'center'">排序号</th>
						<th data-options="field:'level',width:80,align:'center'">级别</th>
						<th data-options="field:'strUpdAt',width:150,align:'center'">最近修改时间</th>
			            <th data-options="field:'id',align:'center',width:400,formatter:formatOperation">操作</th>
					</tr>
				</thead>
			</table>
	  	</div>
	</div>

	<script type="text/javascript">
		function formatStatus(value,row,index) {
			var l_html = '有效';
			if (value==2) {
				l_html = '失效';
			}
			return l_html;
		}
		function formatType(value,row,index) {
			var l_html = '邻里店';
			if (value==2) {
				l_html = '周边商家';
			}
			return l_html;
		}
		function formatOperation(value,row,index) {
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link"  onclick="admin.shopCategory.update('+row.categoryId+',\''+row.name+'\')">编辑</a>';
			if(row.level == 1){
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.shopCategory.add('+row.categoryId+')">添加二级</a>';
			}
			return l_html;
		}
		function changeLevel(level) {
			if (level == 1) {
				$('#dl_parentName').hide()
				$('#parentName').val('');
			} else {
				$('#dl_parentName').show()
			}
		}
	</script>
  </body>
</html>
